package com.ruoyi.bus.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.ruoyi.bus.mapper.WitBusLocationMapper;
import com.ruoyi.bus.domain.WitBusLocation;
import com.ruoyi.bus.service.IWitBusLocationService;

/**
 * 车辆位置Service业务层处理
 * 
 * @author caiyanshan
 * @date 2021-04-28
 */
@Slf4j
@Service
public class WitBusLocationServiceImpl implements IWitBusLocationService 
{
    @Autowired
    private WitBusLocationMapper witBusLocationMapper;

    /**
     * 查询车辆位置
     * 
     * @param locationId 车辆位置ID
     * @return 车辆位置
     */
    @Override
    public WitBusLocation selectWitBusLocationById(Long locationId)
    {
        return witBusLocationMapper.selectWitBusLocationById(locationId);
    }
    
    public List<WitBusLocation> listLocationByRouteId(WitBusLocation witBusLocation){
        return witBusLocationMapper.listLocationByRouteId(witBusLocation);
    }

    /**
     * 查询车辆位置列表
     * 
     * @param witBusLocation 车辆位置
     * @return 车辆位置
     */
    @Override
    public List<WitBusLocation> selectWitBusLocationList(WitBusLocation witBusLocation)
    {
        return witBusLocationMapper.selectWitBusLocationList(witBusLocation);
    }

    /**
     * 新增车辆位置
     * 
     * @param witBusLocation 车辆位置
     * @return 结果
     */
    @Override
    @Async("threadPoolTaskExecutor")//使用特定线程池处理这个批量插入,防止阻塞
    public void insertWitBusLocation(WitBusLocation witBusLocation)
    {
        log.debug("开始插入车辆位置信息");
        witBusLocationMapper.insertWitBusLocation(witBusLocation);
/*        try {
            Thread.sleep(10000l);
        }catch (Exception e){
        
        }*/
        log.debug("结束插入车辆位置信息");
    }

    /**
     * 修改车辆位置
     * 
     * @param witBusLocation 车辆位置
     * @return 结果
     */
    @Override
    public int updateWitBusLocation(WitBusLocation witBusLocation)
    {
        return witBusLocationMapper.updateWitBusLocation(witBusLocation);
    }

    /**
     * 批量删除车辆位置
     * 
     * @param locationIds 需要删除的车辆位置ID
     * @return 结果
     */
    @Override
    public int deleteWitBusLocationByIds(Long[] locationIds)
    {
        return witBusLocationMapper.deleteWitBusLocationByIds(locationIds);
    }

    /**
     * 删除车辆位置信息
     * 
     * @param locationId 车辆位置ID
     * @return 结果
     */
    @Override
    public int deleteWitBusLocationById(Long locationId)
    {
        return witBusLocationMapper.deleteWitBusLocationById(locationId);
    }

    public void deleteWitBusLocationByDays(Integer days){
        witBusLocationMapper.deleteWitBusLocationByDays(days);
    }
    
    public List<WitBusLocation> selectBusLocationByDays(Map<String, Object> paramMap){
        return witBusLocationMapper.selectBusLocationByDays(paramMap);
    }
}
